package taskk;

public class Armi {

    static volatile int iNum = 100000;

    public static void main(String[] args) {

        System.out.println("I'm a King!!!!");
        for (int i = 0; i < iNum; ) {
            int finalI = i;
            new Thread(() -> {
                System.out.println("我是第" + finalI + "个士兵, 保卫King");
                try {
                    Thread.sleep(20000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }).start();
            i++;
        }
        while (true) {
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

}
